/*
 * @Author: levi7754 levi7754@163.com
 * @Date: 2025-10-13 13:50:29
 * @LastEditors: levi7754 levi7754@163.com
 * @LastEditTime: 2025-10-13 13:50:41
 * @FilePath: \udp-nature-mall\utils\useGoods.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { transferI18n } from "@/locale"


export function formatStock(type, num) {
  if (!num) return transferI18n("field.stock") + "  0"
  num = Math.floor(num) + '';
  if (type === 'exact') {
    return transferI18n("field.stock") + " " + num;
  } else {
    if (num < 10) {
      return '库存≤10';
    } else {
      let a = Math.pow(10, num.length - 1);
      return '库存 ' + parseInt(num / a) * a + '+';
    }
  }
}